home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickTime / QuickTime 3 Interfaces & Libs / QTDevWin / CIncludes / SCSI.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-21  |  52.1 KB  |  1,057 lines  |  [TEXT/dosa]

  1. /*
  2.      File:        SCSI.h
  3.  
  4.      Contains:    SCSI Family Interfaces.
  5.  
  6.      Version:    Technology:    SCSI 4.3
  7.                  Release:    QuickTime 3.0
  8.  
  9.      Copyright:    © 1986-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __SCSI__
  19. #define __SCSI__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28.  
  29.  
  30. #if PRAGMA_ONCE
  31. #pragma once
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #if PRAGMA_IMPORT
  39. #pragma import on
  40. #endif
  41.  
  42. #if PRAGMA_STRUCT_ALIGN
  43.     #pragma options align=mac68k
  44. #elif PRAGMA_STRUCT_PACKPUSH
  45.     #pragma pack(push, 2)
  46. #elif PRAGMA_STRUCT_PACK
  47.     #pragma pack(2)
  48. #endif
  49.  
  50. /* SCSI Manager errors. These are generated by Inside Mac IV calls only. */
  51.  
  52. enum {
  53.     scCommErr                    = 2,                            /* communications error, operation timeout */
  54.     scArbNBErr                    = 3,                            /* arbitration timeout waiting for not BSY */
  55.     scBadParmsErr                = 4,                            /* bad parameter or TIB opcode */
  56.     scPhaseErr                    = 5,                            /* SCSI bus not in correct phase for attempted operation */
  57.     scCompareErr                = 6,                            /* data compare error */
  58.     scMgrBusyErr                = 7,                            /* SCSI Manager busy  */
  59.     scSequenceErr                = 8,                            /* attempted operation is out of sequence */
  60.     scBusTOErr                    = 9,                            /* CPU bus timeout */
  61.     scComplPhaseErr                = 10                            /* SCSI bus wasn't in Status phase */
  62. };
  63.  
  64. /* TIB opcodes */
  65.  
  66. enum {
  67.     scInc                        = 1,
  68.     scNoInc                        = 2,
  69.     scAdd                        = 3,
  70.     scMove                        = 4,
  71.     scLoop                        = 5,
  72.     scNop                        = 6,
  73.     scStop                        = 7,
  74.     scComp                        = 8
  75. };
  76.  
  77. /* Signatures */
  78.  
  79. enum {
  80.     sbSIGWord                    = 0x4552,                        /* signature word for Block 0 ('ER') */
  81.     sbMac                        = 1,                            /* system type for Mac */
  82.     pMapSIG                        = 0x504D,                        /* partition map signature ('PM') */
  83.     pdSigWord                    = 0x5453
  84. };
  85.  
  86.  
  87. enum {
  88.     oldPMSigWord                = pdSigWord,
  89.     newPMSigWord                = pMapSIG
  90. };
  91.  
  92. /* Driver Descriptor Map */
  93.  
  94. struct Block0 {
  95.     unsigned short                     sbSig;                        /* unique value for SCSI block 0 */
  96.     unsigned short                     sbBlkSize;                    /* block size of device */
  97.     unsigned long                     sbBlkCount;                    /* number of blocks on device */
  98.     unsigned short                     sbDevType;                    /* device type */
  99.     unsigned short                     sbDevId;                    /* device id */
  100.     unsigned long                     sbData;                        /* not used */
  101.     unsigned short                     sbDrvrCount;                /* driver descriptor count */
  102.     unsigned long                     ddBlock;                    /* 1st driver's starting block */
  103.     unsigned short                     ddSize;                        /* size of 1st driver (512-byte blks) */
  104.     unsigned short                     ddType;                        /* system type (1 for Mac+) */
  105.     unsigned short                     ddPad[243];                    /* ARRAY[0..242] OF INTEGER; not used */
  106. };
  107. typedef struct Block0                    Block0;
  108. /* Driver descriptor */
  109.  
  110. struct DDMap {
  111.     unsigned long                     ddBlock;                    /* 1st driver's starting block */
  112.     unsigned short                     ddSize;                        /* size of 1st driver (512-byte blks) */
  113.     unsigned short                     ddType;                        /* system type (1 for Mac+) */
  114. };
  115. typedef struct DDMap                    DDMap;
  116. /* Partition Map Entry */
  117.  
  118. struct Partition {
  119.     unsigned short                     pmSig;                        /* unique value for map entry blk */
  120.     unsigned short                     pmSigPad;                    /* currently unused */
  121.     unsigned long                     pmMapBlkCnt;                /* # of blks in partition map */
  122.     unsigned long                     pmPyPartStart;                /* physical start blk of partition */
  123.     unsigned long                     pmPartBlkCnt;                /* # of blks in this partition */
  124.     unsigned char                     pmPartName[32];                /* ASCII partition name */
  125.     unsigned char                     pmParType[32];                /* ASCII partition type */
  126.     unsigned long                     pmLgDataStart;                /* log. # of partition's 1st data blk */
  127.     unsigned long                     pmDataCnt;                    /* # of blks in partition's data area */
  128.     unsigned long                     pmPartStatus;                /* bit field for partition status */
  129.     unsigned long                     pmLgBootStart;                /* log. blk of partition's boot code */
  130.     unsigned long                     pmBootSize;                    /* number of bytes in boot code */
  131.     unsigned long                     pmBootAddr;                    /* memory load address of boot code */
  132.     unsigned long                     pmBootAddr2;                /* currently unused */
  133.     unsigned long                     pmBootEntry;                /* entry point of boot code */
  134.     unsigned long                     pmBootEntry2;                /* currently unused */
  135.     unsigned long                     pmBootCksum;                /* checksum of boot code */
  136.     unsigned char                     pmProcessor[16];            /* ASCII for the processor type */
  137.     unsigned short                     pmPad[188];                    /* ARRAY[0..187] OF INTEGER; not used */
  138. };
  139. typedef struct Partition                Partition;
  140. /* TIB instruction */
  141.  
  142. struct SCSIInstr {
  143.     unsigned short                     scOpcode;
  144.     long                             scParam1;
  145.     long                             scParam2;
  146. };
  147. typedef struct SCSIInstr                SCSIInstr;
  148. /* SCSI Phases (used by SIMs to support the Original SCSI Manager */
  149.  
  150. enum {
  151.     kDataOutPhase                = 0,                            /* Encoded MSG, C/D, I/O bits */
  152.     kDataInPhase                = 1,
  153.     kCommandPhase                = 2,
  154.     kStatusPhase                = 3,
  155.     kPhaseIllegal0                = 4,
  156.     kPhaseIllegal1                = 5,
  157.     kMessageOutPhase            = 6,
  158.     kMessageInPhase                = 7,
  159.     kBusFreePhase                = 8,                            /* Additional Phases */
  160.     kArbitratePhase                = 9,
  161.     kSelectPhase                = 10,
  162.     kMessageInPhaseNACK            = 11                            /* Message In Phase with ACK hanging on the bus */
  163. };
  164.  
  165.  
  166. EXTERN_API( OSErr )
  167. SCSIReset                        (void)                                                        TWOWORDINLINE(0x4267, 0xA815);
  168.  
  169. EXTERN_API( OSErr )
  170. SCSIGet                            (void)                                                        THREEWORDINLINE(0x3F3C, 0x0001, 0xA815);
  171.  
  172. EXTERN_API( OSErr )
  173. SCSISelect                        (short                     targetID)                            THREEWORDINLINE(0x3F3C, 0x0002, 0xA815);
  174.  
  175. EXTERN_API( OSErr )
  176. SCSICmd                            (Ptr                     buffer,
  177.                                  short                     count)                                THREEWORDINLINE(0x3F3C, 0x0003, 0xA815);
  178.  
  179. EXTERN_API( OSErr )
  180. SCSIRead                        (Ptr                     tibPtr)                                THREEWORDINLINE(0x3F3C, 0x0005, 0xA815);
  181.  
  182. EXTERN_API( OSErr )
  183. SCSIRBlind                        (Ptr                     tibPtr)                                THREEWORDINLINE(0x3F3C, 0x0008, 0xA815);
  184.  
  185. EXTERN_API( OSErr )
  186. SCSIWrite                        (Ptr                     tibPtr)                                THREEWORDINLINE(0x3F3C, 0x0006, 0xA815);
  187.  
  188. EXTERN_API( OSErr )
  189. SCSIWBlind                        (Ptr                     tibPtr)                                THREEWORDINLINE(0x3F3C, 0x0009, 0xA815);
  190.  
  191. EXTERN_API( OSErr )
  192. SCSIComplete                    (short *                stat,
  193.                                  short *                message,
  194.                                  unsigned long             wait)                                THREEWORDINLINE(0x3F3C, 0x0004, 0xA815);
  195.  
  196. EXTERN_API( short )
  197. SCSIStat                        (void)                                                        THREEWORDINLINE(0x3F3C, 0x000A, 0xA815);
  198.  
  199. EXTERN_API( OSErr )
  200. SCSISelAtn                        (short                     targetID)                            THREEWORDINLINE(0x3F3C, 0x000B, 0xA815);
  201.  
  202. EXTERN_API( OSErr )
  203. SCSIMsgIn                        (short *                message)                            THREEWORDINLINE(0x3F3C, 0x000C, 0xA815);
  204.  
  205. EXTERN_API( OSErr )
  206. SCSIMsgOut                        (short                     message)                            THREEWORDINLINE(0x3F3C, 0x000D, 0xA815);
  207.  
  208.  
  209.  
  210. enum {
  211.     scsiVERSION                    = 43
  212. };
  213.  
  214.  
  215. /*
  216.  * SCSI Callback Procedure Prototypes. Several of these are only callable
  217.  * from SCSI Manager 4.3 SIM and XPT contexts. 
  218.  */
  219. typedef CALLBACK_API_C( void , AENCallbackProcPtr )(void );
  220. typedef CALLBACK_API_C( OSErr , SIMInitProcPtr )(Ptr SIMinfoPtr);
  221. typedef CALLBACK_API_C( void , SIMActionProcPtr )(void *scsiPB, Ptr SIMGlobals);
  222. typedef CALLBACK_API_C( void , SCSIProcPtr )(void );
  223. typedef CALLBACK_API_C( void , SCSIMakeCallbackProcPtr )(void *scsiPB);
  224. /* SCSIInterruptPollProcPtr is obsolete (use SCSIInterruptProcPtr) but still here for compatibility */
  225. typedef CALLBACK_API_C( long , SCSIInterruptPollProcPtr )(Ptr SIMGlobals);
  226. typedef CALLBACK_API_C( long , SCSIInterruptProcPtr )(Ptr SIMGlobals);
  227. typedef STACK_UPP_TYPE(AENCallbackProcPtr)                         AENCallbackUPP;
  228. typedef STACK_UPP_TYPE(SIMInitProcPtr)                             SIMInitUPP;
  229. typedef STACK_UPP_TYPE(SIMActionProcPtr)                         SIMActionUPP;
  230. typedef STACK_UPP_TYPE(SCSIProcPtr)                             SCSIUPP;
  231. typedef STACK_UPP_TYPE(SCSIMakeCallbackProcPtr)                 SCSIMakeCallbackUPP;
  232. typedef STACK_UPP_TYPE(SCSIInterruptPollProcPtr)                 SCSIInterruptPollUPP;
  233. typedef STACK_UPP_TYPE(SCSIInterruptProcPtr)                     SCSIInterruptUPP;
  234. typedef CALLBACK_API( void , SCSICallbackProcPtr )(void *scsiPB);
  235. typedef STACK_UPP_TYPE(SCSICallbackProcPtr)                     SCSICallbackUPP;
  236. enum { uppAENCallbackProcInfo = 0x00000001 };                     /* no_return_value Func() */
  237. enum { uppSIMInitProcInfo = 0x000000E1 };                         /* 2_bytes Func(4_bytes) */
  238. enum { uppSIMActionProcInfo = 0x000003C1 };                     /* no_return_value Func(4_bytes, 4_bytes) */
  239. enum { uppSCSIProcInfo = 0x00000001 };                             /* no_return_value Func() */
  240. enum { uppSCSIMakeCallbackProcInfo = 0x000000C1 };                 /* no_return_value Func(4_bytes) */
  241. enum { uppSCSIInterruptPollProcInfo = 0x000000F1 };             /* 4_bytes Func(4_bytes) */
  242. enum { uppSCSIInterruptProcInfo = 0x000000F1 };                 /* 4_bytes Func(4_bytes) */
  243. enum { uppSCSICallbackProcInfo = 0x000000C0 };                     /* pascal no_return_value Func(4_bytes) */
  244. #define NewAENCallbackProc(userRoutine)                         (AENCallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppAENCallbackProcInfo, GetCurrentArchitecture())
  245. #define NewSIMInitProc(userRoutine)                             (SIMInitUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIMInitProcInfo, GetCurrentArchitecture())
  246. #define NewSIMActionProc(userRoutine)                             (SIMActionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIMActionProcInfo, GetCurrentArchitecture())
  247. #define NewSCSIProc(userRoutine)                                 (SCSIUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIProcInfo, GetCurrentArchitecture())
  248. #define NewSCSIMakeCallbackProc(userRoutine)                     (SCSIMakeCallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIMakeCallbackProcInfo, GetCurrentArchitecture())
  249. #define NewSCSIInterruptPollProc(userRoutine)                     (SCSIInterruptPollUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIInterruptPollProcInfo, GetCurrentArchitecture())
  250. #define NewSCSIInterruptProc(userRoutine)                         (SCSIInterruptUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSIInterruptProcInfo, GetCurrentArchitecture())
  251. #define NewSCSICallbackProc(userRoutine)                         (SCSICallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSCSICallbackProcInfo, GetCurrentArchitecture())
  252. #define CallAENCallbackProc(userRoutine)                         CALL_ZERO_PARAMETER_UPP((userRoutine), uppAENCallbackProcInfo)
  253. #define CallSIMInitProc(userRoutine, SIMinfoPtr)                 CALL_ONE_PARAMETER_UPP((userRoutine), uppSIMInitProcInfo, (SIMinfoPtr))
  254. #define CallSIMActionProc(userRoutine, scsiPB, SIMGlobals)         CALL_TWO_PARAMETER_UPP((userRoutine), uppSIMActionProcInfo, (scsiPB), (SIMGlobals))
  255. #define CallSCSIProc(userRoutine)                                 CALL_ZERO_PARAMETER_UPP((userRoutine), uppSCSIProcInfo)
  256. #define CallSCSIMakeCallbackProc(userRoutine, scsiPB)             CALL_ONE_PARAMETER_UPP((userRoutine), uppSCSIMakeCallbackProcInfo, (scsiPB))
  257. #define CallSCSIInterruptPollProc(userRoutine, SIMGlobals)         CALL_ONE_PARAMETER_UPP((userRoutine), uppSCSIInterruptPollProcInfo, (SIMGlobals))
  258. #define CallSCSIInterruptProc(userRoutine, SIMGlobals)             CALL_ONE_PARAMETER_UPP((userRoutine), uppSCSIInterruptProcInfo, (SIMGlobals))
  259. #define CallSCSICallbackProc(userRoutine, scsiPB)                 CALL_ONE_PARAMETER_UPP((userRoutine), uppSCSICallbackProcInfo, (scsiPB))
  260. /* SCSI Manager 4.3 function codes */
  261.  
  262. enum {
  263.     SCSINop                        = 0x00,                            /* Execute nothing                                         */
  264.     SCSIExecIO                    = 0x01,                            /* Execute the specified IO                             */
  265.     SCSIBusInquiry                = 0x03,                            /* Get parameters for entire path of HBAs                 */
  266.     SCSIReleaseQ                = 0x04,                            /* Release the frozen SIM queue for particular LUN         */
  267.     SCSIAbortCommand            = 0x10,                            /* Abort the selected Control Block                      */
  268.     SCSIResetBus                = 0x11,                            /* Reset the SCSI bus                                      */
  269.     SCSIResetDevice                = 0x12,                            /* Reset the SCSI device                                  */
  270.     SCSITerminateIO                = 0x13,                            /* Terminate any pending IO                              */
  271.     SCSIGetVirtualIDInfo        = 0x80,                            /* Find out which bus old ID is on                         */
  272.     SCSILoadDriver                = 0x82,                            /* Load a driver for a device ident                     */
  273.     SCSIOldCall                    = 0x84,                            /* XPT->SIM private call for old-API                     */
  274.     SCSICreateRefNumXref        = 0x85,                            /* Register a DeviceIdent to drvr RefNum xref             */
  275.     SCSILookupRefNumXref        = 0x86,                            /* Get DeviceIdent to drvr RefNum xref                     */
  276.     SCSIRemoveRefNumXref        = 0x87,                            /* Remove a DeviceIdent to drvr RefNum xref             */
  277.     SCSIRegisterWithNewXPT        = 0x88,                            /* XPT has changed - SIM needs to re-register itself     */
  278.     vendorUnique                = 0xC0                            /* 0xC0 thru 0xFF */
  279. };
  280.  
  281.  
  282. /* Allocation length defines for some of the fields */
  283.  
  284. enum {
  285.     handshakeDataLength            = 8,                            /* Handshake data length */
  286.     maxCDBLength                = 16,                            /* Space for the CDB bytes/pointer */
  287.     vendorIDLength                = 16                            /* ASCII string len for Vendor ID  */
  288. };
  289.  
  290. /* Define DeviceIdent structure */
  291.  
  292. struct DeviceIdent {
  293.     UInt8                             diReserved;                    /* reserved                 */
  294.     UInt8                             bus;                        /* SCSI - Bus Number        */
  295.     UInt8                             targetID;                    /* SCSI - Target SCSI ID    */
  296.     UInt8                             LUN;                        /* SCSI - LUN                  */
  297. };
  298. typedef struct DeviceIdent                DeviceIdent;
  299. /* Command Descriptor Block structure */
  300.  
  301. union CDB {
  302.     BytePtr                         cdbPtr;                        /* pointer to the CDB, or */
  303.     UInt8                             cdbBytes[16];                /* the actual CDB to send */
  304. };
  305. typedef union CDB                        CDB;
  306. typedef CDB *                            CDBPtr;
  307. /* Scatter/gather list element (Deprecated for MacOS8) */
  308.  
  309. struct SGRecord {
  310.     Ptr                             SGAddr;
  311.     UInt32                             SGCount;
  312. };
  313. typedef struct SGRecord                    SGRecord;
  314.  
  315. #define SCSIPBHdr                         \
  316.     struct SCSIHdr* qLink;                \
  317.     short            scsiReserved1;        \
  318.     UInt16            scsiPBLength;        \
  319.     UInt8            scsiFunctionCode;    \
  320.     UInt8            scsiReserved2;        \
  321.     volatile OSErr    scsiResult;            \
  322.     DeviceIdent        scsiDevice;            \
  323.     SCSICallbackUPP    scsiCompletion;        \
  324.     UInt32            scsiFlags;            \
  325.     UInt8 *            scsiDriverStorage;    \
  326.     Ptr                scsiXPTprivate;        \
  327.     long            scsiReserved3;
  328.  
  329.  
  330. struct SCSIHdr {
  331.     struct SCSIHdr *                qLink;                        /* (internal use, must be nil on entry)    */
  332.     short                             scsiReserved1;                /* ->     reserved for input                */
  333.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  334.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  335.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  336.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  337.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  338.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  339.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  340.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  341.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  342.     long                             scsiReserved3;                /* reserved                                */
  343. };
  344. typedef struct SCSIHdr                    SCSIHdr;
  345.  
  346. struct SCSI_PB {
  347.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  348.     short                             scsiReserved1;                /* ->     reserved for input                */
  349.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  350.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  351.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  352.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  353.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  354.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  355.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  356.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  357.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  358.     long                             scsiReserved3;                /* reserved                                */
  359. };
  360. typedef struct SCSI_PB                    SCSI_PB;
  361.  
  362. struct SCSI_IO {
  363.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  364.     short                             scsiReserved1;                /* ->     reserved for input                */
  365.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  366.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  367.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  368.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  369.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  370.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  371.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  372.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  373.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  374.     long                             scsiReserved3;                /* reserved                                */
  375.  
  376.     UInt16                             scsiResultFlags;            /* <- Flags which modify the scsiResult field        */
  377.     UInt16                             scsiReserved3pt5;            /* -> Reserved                                        */
  378.     BytePtr                         scsiDataPtr;                /* -> Pointer to the data buffer or the S/G list      */
  379.     UInt32                             scsiDataLength;                /* -> Data transfer length                            */
  380.     BytePtr                         scsiSensePtr;                /* -> Ptr to autosense data buffer                  */
  381.     UInt8                             scsiSenseLength;            /* -> size of the autosense buffer                     */
  382.     UInt8                             scsiCDBLength;                /* -> Number of bytes for the CDB                      */
  383.     UInt16                             scsiSGListCount;            /* -> num of scatter gather list entries              */
  384.     UInt32                             scsiReserved4;                /* <-     reserved for output                            */
  385.     UInt8                             scsiSCSIstatus;                /* <- Returned scsi device status                      */
  386.     SInt8                             scsiSenseResidual;            /* <- Autosense residual length                      */
  387.     UInt16                             scsiReserved5;                /* <-     reserved for output                             */
  388.     long                             scsiDataResidual;            /* <- Returned Transfer residual length              */
  389.     CDB                             scsiCDB;                    /* -> Actual CDB or pointer to CDB                  */
  390.     long                             scsiTimeout;                /* -> Timeout value (Time Mgr format) (CAM timeout) */
  391.     BytePtr                         scsiReserved5pt5;            /* -> Reserved                                        */
  392.     UInt16                             scsiReserved5pt6;            /* -> Reserved                                        */
  393.     UInt16                             scsiIOFlags;                /* -> additional I/O flags                               */
  394.     UInt8                             scsiTagAction;                /* -> What to do for tag queuing                       */
  395.     UInt8                             scsiReserved6;                /* ->     reserved for input                             */
  396.     UInt16                             scsiReserved7;                /* ->     reserved for input                             */
  397.     UInt16                             scsiSelectTimeout;            /* -> Select timeout value                             */
  398.     UInt8                             scsiDataType;                /* -> Data description type (i.e. buffer, TIB, S/G)    */
  399.     UInt8                             scsiTransferType;            /* -> Transfer type (i.e. Blind vs Polled)             */
  400.     UInt32                             scsiReserved8;                /* ->     reserved for input                             */
  401.     UInt32                             scsiReserved9;                /* ->     reserved for input                             */
  402.     UInt16                             scsiHandshake[8];            /* -> handshaking points (null term'd)    */
  403.     UInt32                             scsiReserved10;                /* ->     reserved for input                             */
  404.     UInt32                             scsiReserved11;                /* ->   reserved for input                            */
  405.     struct SCSI_IO *                scsiCommandLink;            /* -> Ptr to the next PB in linked cmd chain         */
  406.  
  407.     UInt8                             scsiSIMpublics[8];            /* ->     reserved for input to 3rd-party SIMs        */
  408.     UInt8                             scsiAppleReserved6[8];        /* ->    reserved for input                              */
  409.  
  410.                                                                 /* XPT layer privates (for old-API emulation) */
  411.  
  412.     UInt16                             scsiCurrentPhase;            /* <- phase upon completing old call                  */
  413.     short                             scsiSelector;                /* -> selector specified in old calls                  */
  414.     OSErr                             scsiOldCallResult;            /* <- result of old call                              */
  415.     UInt8                             scsiSCSImessage;            /* <- Returned scsi device message (for SCSIComplete)*/
  416.     UInt8                             XPTprivateFlags;            /* <> various flags                                   */
  417.     UInt8                             XPTextras[12];                /*                                                    */
  418. };
  419. typedef struct SCSI_IO                    SCSI_IO;
  420.  
  421. typedef SCSI_IO                         SCSIExecIOPB;
  422. /* Bus inquiry PB */
  423.  
  424. struct SCSIBusInquiryPB {
  425.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  426.     short                             scsiReserved1;                /* ->     reserved for input                */
  427.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  428.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  429.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  430.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  431.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  432.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  433.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  434.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  435.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  436.     long                             scsiReserved3;                /* reserved                                */
  437.  
  438.     UInt16                             scsiEngineCount;            /* <- Number of engines on HBA                         */
  439.     UInt16                             scsiMaxTransferType;        /* <- Number of transfer types for this HBA            */
  440.  
  441.     UInt32                             scsiDataTypes;                /* <- which data types are supported by this SIM     */
  442.  
  443.     UInt16                             scsiIOpbSize;                /* <- Size of SCSI_IO PB for this SIM/HBA             */
  444.     UInt16                             scsiMaxIOpbSize;            /* <- Size of max SCSI_IO PB for all SIM/HBAs         */
  445.  
  446.     UInt32                             scsiFeatureFlags;            /* <- Supported features flags field                 */
  447.  
  448.     UInt8                             scsiVersionNumber;            /* <- Version number for the SIM/HBA                 */
  449.     UInt8                             scsiHBAInquiry;                /* <- Mimic of INQ byte 7 for the HBA                 */
  450.     UInt8                             scsiTargetModeFlags;        /* <- Flags for target mode support                 */
  451.     UInt8                             scsiScanFlags;                /* <- Scan related feature flags                     */
  452.  
  453.     UInt32                             scsiSIMPrivatesPtr;            /* <- Ptr to SIM private data area                     */
  454.     UInt32                             scsiSIMPrivatesSize;        /* <- Size of SIM private data area                 */
  455.     UInt32                             scsiAsyncFlags;                /* <- Event cap. for Async Callback                 */
  456.  
  457.     UInt8                             scsiHiBusID;                /* <- Highest path ID in the subsystem              */
  458.     UInt8                             scsiInitiatorID;            /* <- ID of the HBA on the SCSI bus                 */
  459.     UInt16                             scsiBIReserved0;            /*                                                    */
  460.  
  461.     UInt32                             scsiBIReserved1;            /* <-                                                  */
  462.     UInt32                             scsiFlagsSupported;            /* <- which scsiFlags are supported                 */
  463.  
  464.     UInt16                             scsiIOFlagsSupported;        /* <- which scsiIOFlags are supported                 */
  465.     UInt16                             scsiWeirdStuff;                /* <-                                                 */
  466.     UInt16                             scsiMaxTarget;                /* <- maximum Target number supported                 */
  467.     UInt16                             scsiMaxLUN;                    /* <- maximum Logical Unit number supported         */
  468.  
  469.     char                             scsiSIMVendor[16];            /* <- Vendor ID of SIM (or XPT if bus<FF)         */
  470.     char                             scsiHBAVendor[16];            /* <- Vendor ID of the HBA                         */
  471.     char                             scsiControllerFamily[16];    /* <- Family of SCSI Controller                 */
  472.     char                             scsiControllerType[16];        /* <- Specific Model of SCSI Controller used     */
  473.  
  474.     char                             scsiXPTversion[4];            /* <- version number of XPT                         */
  475.     char                             scsiSIMversion[4];            /* <- version number of SIM                         */
  476.     char                             scsiHBAversion[4];            /* <- version number of HBA                         */
  477.  
  478.     UInt8                             scsiHBAslotType;            /* <- type of "slot" that this HBA is in            */
  479.     UInt8                             scsiHBAslotNumber;            /* <- slot number of this HBA                         */
  480.     UInt16                             scsiSIMsRsrcID;                /* <- resource ID of this SIM                         */
  481.  
  482.     UInt16                             scsiBIReserved3;            /* <-                                                 */
  483.     UInt16                             scsiAdditionalLength;        /* <- additional BusInquiry PB len                    */
  484. };
  485. typedef struct SCSIBusInquiryPB            SCSIBusInquiryPB;
  486. /* Abort SIM Request PB */
  487.  
  488. struct SCSIAbortCommandPB {
  489.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  490.     short                             scsiReserved1;                /* ->     reserved for input                */
  491.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  492.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  493.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  494.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  495.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  496.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  497.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  498.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  499.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  500.     long                             scsiReserved3;                /* reserved                                */
  501.     SCSI_IO *                        scsiIOptr;                    /* Pointer to the PB to abort            */
  502. };
  503. typedef struct SCSIAbortCommandPB        SCSIAbortCommandPB;
  504. /* Terminate I/O Process Request PB */
  505.  
  506. struct SCSITerminateIOPB {
  507.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  508.     short                             scsiReserved1;                /* ->     reserved for input                */
  509.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  510.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  511.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  512.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  513.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  514.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  515.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  516.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  517.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  518.     long                             scsiReserved3;                /* reserved                                */
  519.     SCSI_IO *                        scsiIOptr;                    /* Pointer to the PB to terminate         */
  520. };
  521. typedef struct SCSITerminateIOPB        SCSITerminateIOPB;
  522. /* Reset SCSI Bus PB */
  523.  
  524. struct SCSIResetBusPB {
  525.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  526.     short                             scsiReserved1;                /* ->     reserved for input                */
  527.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  528.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  529.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  530.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  531.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  532.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  533.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  534.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  535.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  536.     long                             scsiReserved3;                /* reserved                                */
  537. };
  538. typedef struct SCSIResetBusPB            SCSIResetBusPB;
  539. /* Reset SCSI Device PB */
  540.  
  541. struct SCSIResetDevicePB {
  542.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  543.     short                             scsiReserved1;                /* ->     reserved for input                */
  544.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  545.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  546.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  547.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  548.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  549.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  550.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  551.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  552.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  553.     long                             scsiReserved3;                /* reserved                                */
  554. };
  555. typedef struct SCSIResetDevicePB        SCSIResetDevicePB;
  556. /* Release SIM Queue PB */
  557.  
  558. struct SCSIReleaseQPB {
  559.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  560.     short                             scsiReserved1;                /* ->     reserved for input                */
  561.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  562.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  563.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  564.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  565.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  566.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  567.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  568.     BytePtr                         scsiDriverStorage;            /* <> Ptr for driver private use        */
  569.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  570.     long                             scsiReserved3;                /* reserved                                */
  571. };
  572. typedef struct SCSIReleaseQPB            SCSIReleaseQPB;
  573. /* SCSI Get Virtual ID Info PB */
  574.  
  575. struct SCSIGetVirtualIDInfoPB {
  576.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  577.     short                             scsiReserved1;                /* ->     reserved for input                */
  578.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  579.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  580.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  581.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  582.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  583.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  584.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  585.     Ptr                             scsiDriverStorage;            /* <> Ptr for driver private use        */
  586.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  587.     long                             scsiReserved3;                /* reserved                                */
  588.     UInt16                             scsiOldCallID;                /* -> SCSI ID of device in question     */
  589.     Boolean                         scsiExists;                    /* <- true if device exists             */
  590.     SInt8                             filler;
  591. };
  592. typedef struct SCSIGetVirtualIDInfoPB    SCSIGetVirtualIDInfoPB;
  593. /* Create/Lookup/Remove RefNum for Device PB */
  594.  
  595. struct SCSIDriverPB {
  596.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  597.     short                             scsiReserved1;                /* ->     reserved for input                */
  598.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  599.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  600.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  601.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  602.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  603.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  604.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  605.     Ptr                             scsiDriverStorage;            /* <> Ptr for driver private use        */
  606.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  607.     long                             scsiReserved3;                /* reserved                                */
  608.     short                             scsiDriver;                    /* -> DriverRefNum, For SetDriver, <- For GetNextDriver */
  609.     UInt16                             scsiDriverFlags;            /* <> Details of driver/device             */
  610.     DeviceIdent                     scsiNextDevice;                /* <- DeviceIdent of the NEXT Item in the list  */
  611. };
  612. typedef struct SCSIDriverPB                SCSIDriverPB;
  613. /* Load Driver PB */
  614.  
  615. struct SCSILoadDriverPB {
  616.     SCSIHdr *                        qLink;                        /* (internal use, must be nil on entry)    */
  617.     short                             scsiReserved1;                /* ->     reserved for input                */
  618.     UInt16                             scsiPBLength;                /* -> Length of the entire PB            */
  619.     UInt8                             scsiFunctionCode;            /* -> function selector                 */
  620.     UInt8                             scsiReserved2;                /* <-     reserved for output                */
  621.     volatile OSErr                     scsiResult;                    /* <- Returned result                     */
  622.     DeviceIdent                     scsiDevice;                    /* -> Device Identifier (bus+target+lun)*/
  623.     SCSICallbackUPP                 scsiCompletion;                /* -> Callback on completion function      */
  624.     UInt32                             scsiFlags;                    /* -> assorted flags                    */
  625.     Ptr                             scsiDriverStorage;            /* <> Ptr for driver private use        */
  626.     Ptr                             scsiXPTprivate;                /* private field for use in XPT            */
  627.     long                             scsiReserved3;                /* reserved                                */
  628.     short                             scsiLoadedRefNum;            /* <- SIM returns refnum of driver         */
  629.     Boolean                         scsiDiskLoadFailed;            /* -> if true, indicates call after failure to load */
  630.     SInt8                             filler;
  631. };
  632. typedef struct SCSILoadDriverPB            SCSILoadDriverPB;
  633.  
  634. /* Defines for the scsiTransferType field */
  635.  
  636. enum {
  637.     scsiTransferBlind            = 0,
  638.     scsiTransferPolled            = 1
  639. };
  640.  
  641.  
  642. enum {
  643.     scsiErrorBase                = -7936
  644. };
  645.  
  646.  
  647. enum {
  648.     scsiRequestInProgress        = 1,                            /* 1     = PB request is in progress             */
  649.                                                                 /* Execution failed  00-2F */
  650.     scsiRequestAborted            = scsiErrorBase + 2,            /* -7934 = PB request aborted by the host         */
  651.     scsiUnableToAbort            = scsiErrorBase + 3,            /* -7933 = Unable to Abort PB request             */
  652.     scsiNonZeroStatus            = scsiErrorBase + 4,            /* -7932 = PB request completed with an err     */
  653.     scsiUnused05                = scsiErrorBase + 5,            /* -7931 =                                      */
  654.     scsiUnused06                = scsiErrorBase + 6,            /* -7930 =                                      */
  655.     scsiUnused07                = scsiErrorBase + 7,            /* -7929 =                                      */
  656.     scsiUnused08                = scsiErrorBase + 8,            /* -7928 =                                      */
  657.     scsiUnableToTerminate        = scsiErrorBase + 9,            /* -7927 = Unable to Terminate I/O PB req         */
  658.     scsiSelectTimeout            = scsiErrorBase + 10,            /* -7926 = Target selection timeout             */
  659.     scsiCommandTimeout            = scsiErrorBase + 11,            /* -7925 = Command timeout                      */
  660.     scsiIdentifyMessageRejected    = scsiErrorBase + 12,            /* -7924 =                                      */
  661.     scsiMessageRejectReceived    = scsiErrorBase + 13,            /* -7923 = Message reject received                 */
  662.     scsiSCSIBusReset            = scsiErrorBase + 14,            /* -7922 = SCSI bus reset sent/received         */
  663.     scsiParityError                = scsiErrorBase + 15,            /* -7921 = Uncorrectable parity error occured     */
  664.     scsiAutosenseFailed            = scsiErrorBase + 16,            /* -7920 = Autosense: Request sense cmd fail     */
  665.     scsiUnused11                = scsiErrorBase + 17,            /* -7919 =                                      */
  666.     scsiDataRunError            = scsiErrorBase + 18,            /* -7918 = Data overrun/underrun error          */
  667.     scsiUnexpectedBusFree        = scsiErrorBase + 19,            /* -7917 = Unexpected BUS free                     */
  668.     scsiSequenceFailed            = scsiErrorBase + 20,            /* -7916 = Target bus phase sequence failure     */
  669.     scsiWrongDirection            = scsiErrorBase + 21,            /* -7915 = Data phase was in wrong direction     */
  670.     scsiUnused16                = scsiErrorBase + 22,            /* -7914 =                                      */
  671.     scsiBDRsent                    = scsiErrorBase + 23,            /* -7913 = A SCSI BDR msg was sent to target     */
  672.     scsiTerminated                = scsiErrorBase + 24,            /* -7912 = PB request terminated by the host     */
  673.     scsiNoNexus                    = scsiErrorBase + 25,            /* -7911 = Nexus is not established             */
  674.     scsiCDBReceived                = scsiErrorBase + 26,            /* -7910 = The SCSI CDB has been received         */
  675.                                                                 /* Couldn't begin execution  30-3F */
  676.     scsiTooManyBuses            = scsiErrorBase + 48,            /* -7888 = Register failed because we're full    */
  677.     scsiBusy                    = scsiErrorBase + 49,            /* -7887 = SCSI subsystem is busy                 */
  678.     scsiProvideFail                = scsiErrorBase + 50,            /* -7886 = Unable to provide requ. capability    */
  679.     scsiDeviceNotThere            = scsiErrorBase + 51,            /* -7885 = SCSI device not installed/there      */
  680.     scsiNoHBA                    = scsiErrorBase + 52,            /* -7884 = No HBA detected Error                 */
  681.     scsiDeviceConflict            = scsiErrorBase + 53,            /* -7883 = sorry, max 1 refNum per DeviceIdent     */
  682.     scsiNoSuchXref                = scsiErrorBase + 54,            /* -7882 = no such RefNum xref                     */
  683.     scsiQLinkInvalid            = scsiErrorBase + 55,            /* -7881 = pre-linked PBs not supported            */
  684.                                                                 /*   (The QLink field was nonzero)                */
  685.                                                                 /* Parameter errors  40-7F */
  686.     scsiPBLengthError            = scsiErrorBase + 64,            /* -7872 = (scsiPBLength is insuf'ct/invalid     */
  687.     scsiFunctionNotAvailable    = scsiErrorBase + 65,            /* -7871 = The requ. func is not available      */
  688.     scsiRequestInvalid            = scsiErrorBase + 66,            /* -7870 = PB request is invalid                 */
  689.     scsiBusInvalid                = scsiErrorBase + 67,            /* -7869 = Bus ID supplied is invalid              */
  690.     scsiTIDInvalid                = scsiErrorBase + 68,            /* -7868 = Target ID supplied is invalid         */
  691.     scsiLUNInvalid                = scsiErrorBase + 69,            /* -7867 = LUN supplied is invalid              */
  692.     scsiIDInvalid                = scsiErrorBase + 70,            /* -7866 = The initiator ID is invalid          */
  693.     scsiDataTypeInvalid            = scsiErrorBase + 71,            /* -7865 = scsiDataType requested not supported */
  694.     scsiTransferTypeInvalid        = scsiErrorBase + 72,            /* -7864 = scsiTransferType field is too high     */
  695.     scsiCDBLengthInvalid        = scsiErrorBase + 73            /* -7863 = scsiCDBLength field is too big         */
  696. };
  697.  
  698. /* New errors for SCSI Family         */
  699.  
  700. enum {
  701.     scsiUnused74                = scsiErrorBase + 74,            /* -7862 =                                          */
  702.     scsiUnused75                = scsiErrorBase + 75,            /* -7861 =                                         */
  703.     scsiBadDataLength            = scsiErrorBase + 76,            /* -7860 = a zero data length in PB             */
  704.     scsiPartialPrepared            = scsiErrorBase + 77,            /* -7859 = could not do full prepare mem for I/O*/
  705.     scsiInvalidMsgType            = scsiErrorBase + 78,            /* -7858 = Invalid message type (internal)        */
  706.     scsiUnused79                = scsiErrorBase + 79,            /* -7857 =                                           */
  707.     scsiBadConnID                = scsiErrorBase + 80,            /* -7856 = Bad Connection ID                      */
  708.     scsiUnused81                = scsiErrorBase + 81,            /* -7855 =                                         */
  709.     scsiIOInProgress            = scsiErrorBase + 82,            /* -7854 = Can't close conn, IO in prog            */
  710.     scsiTargetReserved            = scsiErrorBase + 83,            /* -7853 = Target already reserved                */
  711.     scsiUnused84                = scsiErrorBase + 84,            /* -7852 =                                         */
  712.     scsiUnused85                = scsiErrorBase + 85,            /* -7851 =                                         */
  713.     scsiBadConnType                = scsiErrorBase + 86,            /* -7850 = Bad connection type                    */
  714.     scsiCannotLoadPlugin        = scsiErrorBase + 87            /* -7849 = No matching service category            */
  715. };
  716.  
  717. /* +++ */
  718. /*
  719.  * scsiFamilyInternalError and scsiPluginInternalError are intended to handle consistency check failures.
  720.  * For example, if the family stores a record on a lookaside queue, but does not find that record
  721.  * it can use this error to report this failure. SCSI Manager 4.3 uses dsIOCoreErr in a few places,
  722.  * but this is probably not the best error. In general, internal errors should be reported as bugs.
  723.  *
  724.  * The following range of errors is provided for third-party (non-Apple) SCSI SIM and device driver vendors.
  725.  * In general, they would be used for error conditions that are not covered by the standardized errors.
  726.  * They should not normally be conveyed to normal applications, but might be used for communication between
  727.  * a plug-in and a vendor-provided device driver (for example, to manage RAID hot-swapping).
  728.  *
  729.  * Note: I don't know how many SCSI errors are reserved in the error code architecture. Don't assume that
  730.  * we'll actually get sixteen, but we should reserve at least one.
  731.  */
  732.  
  733. enum {
  734.     scsiFamilyInternalError        = scsiErrorBase + 87,            /* -7849 = Internal consistency check failed    */
  735.     scsiPluginInternalError        = scsiErrorBase + 88,            /* -7848 = Internal consistency check failed    */
  736.     scsiVendorSpecificErrorBase    = scsiErrorBase + 128,            /* ??    = Start of third-party error range        */
  737.     scsiVendorSpecificErrorCount = 16                            /* Number of third-party errors                    */
  738. };
  739.  
  740. /* --- */
  741.  
  742. enum {
  743.     scsiExecutionErrors            = scsiErrorBase,
  744.     scsiNotExecutedErrors        = scsiTooManyBuses,
  745.     scsiParameterErrors            = scsiPBLengthError
  746. };
  747.  
  748. /* Defines for the scsiResultFlags field */
  749.  
  750. enum {
  751.     scsiSIMQFrozen                = 0x0001,                        /* The SIM queue is frozen w/this err            */
  752.     scsiAutosenseValid            = 0x0002,                        /* Autosense data valid for target              */
  753.     scsiBusNotFree                = 0x0004                        /* At time of callback, SCSI bus is not free    */
  754. };
  755.  
  756. /* Defines for the bit numbers of the scsiFlags field in the PB header for the SCSIExecIO function */
  757.  
  758. enum {
  759.     kbSCSIDisableAutosense        = 29,                            /* Disable auto sense feature                     */
  760.     kbSCSIFlagReservedA            = 28,                            /*                                              */
  761.     kbSCSIFlagReserved0            = 27,                            /*                                              */
  762.     kbSCSICDBLinked                = 26,                            /* The PB contains a linked CDB                    */
  763.     kbSCSIQEnable                = 25,                            /* Target queue actions are enabled                */
  764.     kbSCSICDBIsPointer            = 24,                            /* The CDB field contains a pointer                */
  765.     kbSCSIFlagReserved1            = 23,                            /*                                                 */
  766.     kbSCSIInitiateSyncData        = 22,                            /* Attempt Sync data xfer and SDTR                */
  767.     kbSCSIDisableSyncData        = 21,                            /* Disable sync, go to async                    */
  768.     kbSCSISIMQHead                = 20,                            /* Place PB at the head of SIM Q                */
  769.     kbSCSISIMQFreeze            = 19,                            /* Return the SIM Q to frozen state                */
  770.     kbSCSISIMQNoFreeze            = 18,                            /* Disallow SIM Q freezing                        */
  771.     kbSCSIDoDisconnect            = 17,                            /* Definitely do disconnect                        */
  772.     kbSCSIDontDisconnect        = 16,                            /* Definitely don't disconnect                    */
  773.     kbSCSIDataReadyForDMA        = 15,                            /* Data buffer(s) are ready for DMA                */
  774.     kbSCSIFlagReserved3            = 14,                            /*                                                 */
  775.     kbSCSIDataPhysical            = 13,                            /* SG/Buffer data ptrs are physical                */
  776.     kbSCSISensePhysical            = 12,                            /* Autosense buffer ptr is physical                */
  777.     kbSCSIFlagReserved5            = 11,                            /*                                                 */
  778.     kbSCSIFlagReserved6            = 10,                            /*                                                 */
  779.     kbSCSIFlagReserved7            = 9,                            /*                                                 */
  780.     kbSCSIFlagReserved8            = 8,                            /*                                                 */
  781.     kbSCSIDataBufferValid        = 7,                            /* Data buffer valid                            */
  782.     kbSCSIStatusBufferValid        = 6,                            /* Status buffer valid                             */
  783.     kbSCSIMessageBufferValid    = 5,                            /* Message buffer valid                            */
  784.     kbSCSIFlagReserved9            = 4                                /*                                              */
  785. };
  786.  
  787. /* Defines for the bit masks of the scsiFlags field */
  788.  
  789. enum {
  790.     scsiDirectionMask            = (long)0xC0000000,                /* Data direction mask                        */
  791.     scsiDirectionNone            = (long)0xC0000000,                /* Data direction (11: no data)                */
  792.     scsiDirectionReserved        = 0x00000000,                    /* Data direction (00: reserved)            */
  793.     scsiDirectionOut            = (long)0x80000000,                /* Data direction (10: DATA OUT)            */
  794.     scsiDirectionIn                = 0x40000000,                    /* Data direction (01: DATA IN)                */
  795.     scsiDisableAutosense        = 0x20000000,                    /* Disable auto sense feature                */
  796.     scsiFlagReservedA            = 0x10000000,                    /*                                             */
  797.     scsiFlagReserved0            = 0x08000000,                    /*                                             */
  798.     scsiCDBLinked                = 0x04000000,                    /* The PB contains a linked CDB                */
  799.     scsiQEnable                    = 0x02000000,                    /* Target queue actions are enabled            */
  800.     scsiCDBIsPointer            = 0x01000000,                    /* The CDB field contains a pointer            */
  801.     scsiFlagReserved1            = 0x00800000,                    /*                                             */
  802.     scsiInitiateSyncData        = 0x00400000,                    /* Attempt Sync data xfer and SDTR            */
  803.     scsiDisableSyncData            = 0x00200000,                    /* Disable sync, go to async                */
  804.     scsiSIMQHead                = 0x00100000,                    /* Place PB at the head of SIM Q            */
  805.     scsiSIMQFreeze                = 0x00080000,                    /* Return the SIM Q to frozen state            */
  806.     scsiSIMQNoFreeze            = 0x00040000,                    /* Disallow SIM Q freezing                    */
  807.     scsiDoDisconnect            = 0x00020000,                    /* Definitely do disconnect                    */
  808.     scsiDontDisconnect            = 0x00010000,                    /* Definitely don't disconnect                */
  809.     scsiDataReadyForDMA            = 0x00008000,                    /* Data buffer(s) are ready for DMA            */
  810.     scsiFlagReserved3            = 0x00004000,                    /*  */
  811.     scsiDataPhysical            = 0x00002000,                    /* SG/Buffer data ptrs are physical            */
  812.     scsiSensePhysical            = 0x00001000,                    /* Autosense buffer ptr is physical            */
  813.     scsiFlagReserved5            = 0x00000800,                    /*                                          */
  814.     scsiFlagReserved6            = 0x00000400,                    /*                                             */
  815.     scsiFlagReserved7            = 0x00000200,                    /*                                             */
  816.     scsiFlagReserved8            = 0x00000100                    /*                                             */
  817. };
  818.  
  819. /* bit masks for the scsiIOFlags field in SCSIExecIOPB */
  820.  
  821. enum {
  822.     scsiNoParityCheck            = 0x0002,                        /* disable parity checking                             */
  823.     scsiDisableSelectWAtn        = 0x0004,                        /* disable select w/Atn                              */
  824.     scsiSavePtrOnDisconnect        = 0x0008,                        /* do SaveDataPointer upon Disconnect msg             */
  825.     scsiNoBucketIn                = 0x0010,                        /* don’t bit bucket in during this I/O                 */
  826.     scsiNoBucketOut                = 0x0020,                        /* don’t bit bucket out during this I/O             */
  827.     scsiDisableWide                = 0x0040,                        /* disable wide transfer negotiation                 */
  828.     scsiInitiateWide            = 0x0080,                        /* initiate wide transfer negotiation                 */
  829.     scsiRenegotiateSense        = 0x0100,                        /* renegotiate sync/wide before issuing autosense     */
  830.     scsiDisableDiscipline        = 0x0200,                        /* disable parameter checking on SCSIExecIO calls    */
  831.     scsiIOFlagReserved0080        = 0x0080,                        /*                                                  */
  832.     scsiIOFlagReserved8000        = 0x8000                        /*                                                     */
  833. };
  834.  
  835. /* Defines for the Bus Inquiry PB fields. */
  836. /* scsiHBAInquiry field bits */
  837.  
  838. enum {
  839.     scsiBusMDP                    = 0x80,                            /* Supports Modify Data Pointer message                        */
  840.     scsiBusWide32                = 0x40,                            /* Supports 32 bit wide SCSI                                */
  841.     scsiBusWide16                = 0x20,                            /* Supports 16 bit wide SCSI                                */
  842.     scsiBusSDTR                    = 0x10,                            /* Supports Sync Data Transfer Req message                    */
  843.     scsiBusLinkedCDB            = 0x08,                            /* Supports linked CDBs                                        */
  844.     scsiBusTagQ                    = 0x02,                            /* Supports tag queue message                                */
  845.     scsiBusSoftReset            = 0x01                            /* Supports soft reset                                        */
  846. };
  847.  
  848. /* Defines for the scsiDataType field */
  849.  
  850. enum {
  851.     scsiDataBuffer                = 0,                            /* single contiguous buffer supplied                  */
  852.     scsiDataTIB                    = 1,                            /* TIB supplied (ptr in scsiDataPtr)                 */
  853.     scsiDataSG                    = 2,                            /* scatter/gather list supplied                      */
  854.     scsiDataIOTable                = 3                                /*#(7/11/95) Prepared by Block Storage              */
  855. };
  856.  
  857. /* scsiDataTypes field bits  */
  858. /*    bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved */
  859.  
  860. enum {
  861.     scsiBusDataTIB                = (1 << scsiDataTIB),            /* TIB supplied (ptr in scsiDataPtr)        */
  862.     scsiBusDataBuffer            = (1 << scsiDataBuffer),        /* single contiguous buffer supplied         */
  863.     scsiBusDataSG                = (1 << scsiDataSG),            /* scatter/gather list supplied             */
  864.     scsiBusDataIOTable            = (1 << scsiDataIOTable),        /* (2/6/95) Prepare Memory for IO*/
  865.     scsiBusDataReserved            = (long)0x80000000                /*                                           */
  866. };
  867.  
  868. /* scsiScanFlags field bits */
  869.  
  870. enum {
  871.     scsiBusScansDevices            = 0x80,                            /* Bus scans for and maintains device list            */
  872.     scsiBusScansOnInit            = 0x40,                            /* Bus scans performed at power-up/reboot            */
  873.     scsiBusLoadsROMDrivers        = 0x20                            /* may load ROM drivers to support targets             */
  874. };
  875.  
  876. /* scsiFeatureFlags field bits */
  877.  
  878. enum {
  879.     scsiBusInternalExternalMask    = 0x000000C0,                    /* bus internal/external mask                    */
  880.     scsiBusInternalExternalUnknown = 0x00000000,                /* not known whether bus is inside or outside     */
  881.     scsiBusInternalExternal        = 0x000000C0,                    /* bus goes inside and outside the box             */
  882.     scsiBusInternal                = 0x00000080,                    /* bus goes inside the box                         */
  883.     scsiBusExternal                = 0x00000040,                    /* bus goes outside the box                     */
  884.     scsiBusCacheCoherentDMA        = 0x00000020,                    /* DMA is cache coherent                         */
  885.     scsiBusOldCallCapable        = 0x00000010,                    /* SIM is old call capable                         */
  886.     scsiBusDifferential            = 0x00000004,                    /* Single Ended (0) or Differential (1)         */
  887.     scsiBusFastSCSI                = 0x00000002,                    /* HBA supports fast SCSI                         */
  888.     scsiBusDMAavailable            = 0x00000001                    /* DMA is available                             */
  889. };
  890.  
  891. /* scsiWeirdStuff field bits */
  892.  
  893. enum {
  894.     scsiOddDisconnectUnsafeRead1 = 0x0001,                        /* Disconnects on odd byte boundries are unsafe with DMA and/or blind reads */
  895.     scsiOddDisconnectUnsafeWrite1 = 0x0002,                        /* Disconnects on odd byte boundries are unsafe with DMA and/or blind writes */
  896.     scsiBusErrorsUnsafe            = 0x0004,                        /* Non-handshaked delays or disconnects during blind transfers may cause a crash */
  897.     scsiRequiresHandshake        = 0x0008,                        /* Non-handshaked delays or disconnects during blind transfers may cause data corruption */
  898.     scsiTargetDrivenSDTRSafe    = 0x0010,                        /* Targets which initiate synchronous negotiations are supported */
  899.     scsiOddCountForPhysicalUnsafe = 0x0020,                        /* If using physical addrs all counts must be even, and disconnects must be on even boundries */
  900.     scsiAbortCmdFixed            = 0x0040,                        /* Set if abort command is fixed to properly make callbacks */
  901.     scsiMeshACKTimingFixed        = 0x0080                        /* Set if bug allowing Mesh to release ACK prematurely is fixed */
  902. };
  903.  
  904. /* scsiHBAslotType values */
  905.  
  906. enum {
  907.     scsiMotherboardBus            = 0x00,                            /* A built in Apple supplied bus                     */
  908.     scsiNuBus                    = 0x01,                            /* A SIM on a NuBus card                             */
  909.     scsiPDSBus                    = 0x03,                            /*    "  on a PDS card                                */
  910.     scsiPCIBus                    = 0x04,                            /*    "  on a PCI bus card                            */
  911.     scsiPCMCIABus                = 0x05,                            /*    "  on a PCMCIA card                            */
  912.     scsiFireWireBridgeBus        = 0x06                            /*    "  connected through a FireWire bridge        */
  913. };
  914.  
  915. /* Defines for the scsiDriverFlags field (in SCSIDriverPB) */
  916.  
  917. enum {
  918.     scsiDeviceSensitive            = 0x0001,                        /* Only driver should access this device                */
  919.     scsiDeviceNoOldCallAccess    = 0x0002                        /* no old call access to this device                     */
  920. };
  921.  
  922. /*  SIMInitInfo PB */
  923. /* directions are for SCSIRegisterBus call ( -> parm, <- result)             */
  924.  
  925. struct SIMInitInfo {
  926.     Ptr                             SIMstaticPtr;                /* <- alloc. ptr to the SIM's static vars                 */
  927.     long                             staticSize;                    /* -> num bytes SIM needs for static vars                 */
  928.     SIMInitUPP                         SIMInit;                    /* -> pointer to the SIM init routine                     */
  929.     SIMActionUPP                     SIMAction;                    /* -> pointer to the SIM action routine                 */
  930.     SCSIInterruptUPP                 SIM_ISR;                    /*       reserved                                             */
  931.     SCSIInterruptUPP                 SIMInterruptPoll;            /* -> pointer to the SIM interrupt poll routine            */
  932.     SIMActionUPP                     NewOldCall;                    /* -> pointer to the SIM NewOldCall routine                */
  933.     UInt16                             ioPBSize;                    /* -> size of SCSI_IO_PBs required for this SIM            */
  934.     Boolean                         oldCallCapable;                /* -> true if this SIM can handle old-API calls            */
  935.     UInt8                             simInfoUnused1;                /*       reserved                                            */
  936.     long                             simInternalUse;                /* xx not affected or viewed by XPT                        */
  937.     SCSIUPP                         XPT_ISR;                    /*    reserved                                            */
  938.     SCSIUPP                         EnteringSIM;                /* <- ptr to the EnteringSIM routine                    */
  939.     SCSIUPP                         ExitingSIM;                    /* <- ptr to the ExitingSIM routine                        */
  940.     SCSIMakeCallbackUPP             MakeCallback;                /* <- the XPT layer’s SCSIMakeCallback routine            */
  941.     UInt16                             busID;                        /* <- bus number for the registered bus                    */
  942.     UInt8                             simSlotNumber;                /* <- Magic cookie to place in scsiHBASlotNumber (PCI)    */
  943.     UInt8                             simSRsrcID;                    /* <- Magic cookie to place in scsiSIMsRsrcID     (PCI)    */
  944.     Ptr                             simRegEntry;                /* -> The SIM's RegEntryIDPtr                     (PCI)    */
  945. };
  946. typedef struct SIMInitInfo                SIMInitInfo;
  947. /* Glue between SCSI calls and SCSITrap format */
  948.  
  949. enum {
  950.     xptSCSIAction                = 0x0001,
  951.     xptSCSIRegisterBus            = 0x0002,
  952.     xptSCSIDeregisterBus        = 0x0003,
  953.     xptSCSIReregisterBus        = 0x0004,
  954.     xptSCSIKillXPT                = 0x0005,                        /* kills Mini-XPT after transition */
  955.     xptSCSIInitialize            = 0x000A                        /* Initialize the SCSI manager */
  956. };
  957.  
  958. /*
  959.  * SCSI bus status. These values are returned by the SCSI target in the status phase.
  960.  * They are not related to Macintosh status values (except that values other than
  961.  * scsiStatusGood will result in scsiResult set to scsiNonZeroStatus).
  962.  */
  963.  
  964. enum {
  965.     scsiStatGood                = 0x00,                            /* Good Status*/
  966.     scsiStatCheckCondition        = 0x02,                            /* Check Condition*/
  967.     scsiStatConditionMet        = 0x04,                            /* Condition Met*/
  968.     scsiStatBusy                = 0x08,                            /* Busy*/
  969.     scsiStatIntermediate        = 0x10,                            /* Intermediate*/
  970.     scsiStatIntermedMet            = 0x14,                            /* Intermediate - Condition Met*/
  971.     scsiStatResvConflict        = 0x18,                            /* Reservation conflict*/
  972.     scsiStatTerminated            = 0x22,                            /* Command terminated*/
  973.     scsiStatQFull                = 0x28                            /* Queue full*/
  974. };
  975.  
  976. /* SCSI messages*/
  977.  
  978. enum {
  979.     kCmdCompleteMsg                = 0,
  980.     kExtendedMsg                = 1,                            /* 0x01*/
  981.     kSaveDataPointerMsg            = 2,                            /* 0x02*/
  982.     kRestorePointersMsg            = 3,                            /* 0x03*/
  983.     kDisconnectMsg                = 4,                            /* 0x04*/
  984.     kInitiatorDetectedErrorMsg    = 5,                            /* 0x05*/
  985.     kAbortMsg                    = 6,                            /* 0x06*/
  986.     kMsgRejectMsg                = 7,                            /* 0x07*/
  987.     kNoOperationMsg                = 8,                            /* 0x08*/
  988.     kMsgParityErrorMsg            = 9,                            /* 0x09*/
  989.     kLinkedCmdCompleteMsg        = 10,                            /* 0x0a*/
  990.     kLinkedCmdCompleteWithFlagMsg = 11,                            /* 0x0b*/
  991.     kBusDeviceResetMsg            = 12,                            /* 0x0c*/
  992.     kAbortTagMsg                = 13,                            /* 0x0d*/
  993.     kClearQueueMsg                = 14,                            /* 0x0e*/
  994.     kInitiateRecoveryMsg        = 15,                            /* 0x0f*/
  995.     kReleaseRecoveryMsg            = 16,                            /* 0x10*/
  996.     kTerminateIOProcessMsg        = 17,                            /* 0x11*/
  997.     kSimpleQueueTag                = 0x20,                            /* 0x20*/
  998.     kHeadOfQueueTagMsg            = 0x21,                            /* 0x21*/
  999.     kOrderedQueueTagMsg            = 0x22,                            /* 0x22*/
  1000.     kIgnoreWideResidueMsg        = 0x23                            /* 0x23*/
  1001. };
  1002.  
  1003.  
  1004. /* moveq #kSCSIx, D0;  _SCSIAtomic */
  1005.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  1006.                                                                                             #pragma parameter __D0 SCSIAction(__A0)
  1007.                                                                                             #endif
  1008. EXTERN_API( OSErr )
  1009. SCSIAction                        (SCSI_PB *                parameterBlock)                        TWOWORDINLINE(0x7001, 0xA089);
  1010.  
  1011.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  1012.                                                                                             #pragma parameter __D0 SCSIRegisterBus(__A0)
  1013.                                                                                             #endif
  1014. EXTERN_API( OSErr )
  1015. SCSIRegisterBus                    (SIMInitInfo *            parameterBlock)                        TWOWORDINLINE(0x7002, 0xA089);
  1016.  
  1017.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  1018.                                                                                             #pragma parameter __D0 SCSIDeregisterBus(__A0)
  1019.                                                                                             #endif
  1020. EXTERN_API( OSErr )
  1021. SCSIDeregisterBus                (SCSI_PB *                parameterBlock)                        TWOWORDINLINE(0x7003, 0xA089);
  1022.  
  1023.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  1024.                                                                                             #pragma parameter __D0 SCSIReregisterBus(__A0)
  1025.                                                                                             #endif
  1026. EXTERN_API( OSErr )
  1027. SCSIReregisterBus                (SIMInitInfo *            parameterBlock)                        TWOWORDINLINE(0x7004, 0xA089);
  1028.  
  1029.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  1030.                                                                                             #pragma parameter __D0 SCSIKillXPT(__A0)
  1031.                                                                                             #endif
  1032. EXTERN_API( OSErr )
  1033. SCSIKillXPT                        (SIMInitInfo *            parameterBlock)                        TWOWORDINLINE(0x7005, 0xA089);
  1034.  
  1035.  
  1036.  
  1037. #if PRAGMA_STRUCT_ALIGN
  1038.     #pragma options align=reset
  1039. #elif PRAGMA_STRUCT_PACKPUSH
  1040.     #pragma pack(pop)
  1041. #elif PRAGMA_STRUCT_PACK
  1042.     #pragma pack()
  1043. #endif
  1044.  
  1045. #ifdef PRAGMA_IMPORT_OFF
  1046. #pragma import off
  1047. #elif PRAGMA_IMPORT
  1048. #pragma import reset
  1049. #endif
  1050.  
  1051. #ifdef __cplusplus
  1052. }
  1053. #endif
  1054.  
  1055. #endif /* __SCSI__ */
  1056.  
  1057.